package com.ck.express.tcp

import android.util.Log
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.SimpleChannelInboundHandler

class DownClientInboundHandler  : SimpleChannelInboundHandler<String>() {
    override fun channelRead0(ctx: ChannelHandlerContext, msg: String) {
        Log.i("ClientInboundHandler", "下车接收到消息: $msg")

        // 直接处理字符串消息
        TcpOperationDownClient.receive(msg.substring(8))
    }

    override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
        Log.e("ClientInboundHandler", "处理消息时发生异常: ${cause.message}", cause)
        ctx.close()
    }
}